<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true">
      <el-form-item label="流程定义名称" prop="roleName">
        <el-input
          v-model="queryParams.roleName"
          placeholder="请输入流程定义名称"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="流程定义key" prop="roleKey">
        <el-input
          v-model="queryParams.roleKey"
          placeholder="请输入key"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" >重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="definitionList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" prop="id" :show-overflow-tooltip="true" width="160" align="center"/>
      <el-table-column label="name" prop="name" width="120" align="center"/>
      <el-table-column label="key" prop="modelKey" :show-overflow-tooltip="true" width="100" align="center" />
      <el-table-column label="分类" prop="category" :show-overflow-tooltip="true" width="190" align="center"/>
      <el-table-column label="部署Id" prop="deploymentId" :show-overflow-tooltip="true" width="100" />
      <el-table-column label="状态" prop="suspensionState" align="center" width="100" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope" v-if="scope.row.roleId !== 1">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
          >删除</el-button>
          <el-dropdown size="mini">
            <el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item icon="el-icon-circle-check" >数据权限</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getDefinitionList } from '@/api/bpmn/definition'

export default {
  name: 'Definition',
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        key: undefined,
        name: undefined,
        status: undefined
      },
      // 遮罩层
      loading: false,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      definitionList: []
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      this.loading = true
      getDefinitionList({
        query: {
          pageNum: this.queryParams.pageNum - 1,
          pageSize: this.queryParams.pageSize
        }
      }).then(response => {
        console.log(response.data)
        this.definitionList = response.data.records
        this.total = response.data.total
        this.loading = false
      })
    },
    handleQuery() {},
    handleSelectionChange() {}
  }
}
</script>

<style scoped>

</style>
